<?php
$data  = $this->data;
$roles = $this->roles;

function checkRoles($roles, $roleCheck) {
	foreach ($roles as $value) {
		if($value == $roleCheck) {echo 'checked="true"'; return;}
	}
	echo ''; return;
}
?>
<form method="post" action="/admin/user-group/edit">
<input type="hidden" name="id" value="<?php echo $data['id'] ?>" />
<div class="mainpage">
	<div class="top-tools">
        <?php echo $this->flashMessenger()?>
        <a href="/admin/user-group/index" class="exit  btn " ><i class="icon-hand-left hint" data-hint-msg="Thoát"></i></a>
        <div class="pull-right">
        </div>
        <div class="clear"></div>
    </div>
    <div class="row-fluid">
        <h3 class="form-legend">Edit group user</h3>
    </div>

    <div class="row-fluid">
		<table border="0" width="100%" cellpadding="5" class="form">
		    <tbody>
			    <tr>
			        <td class="form-label">
			            Name:
			        </td>
			        <td class="form-input">
			            <input type="text" name="group-title" style="width: 200px;" class="text" value="<?php echo $data['title'] ?>">
			        </td>
			    </tr>
			    <tr>
			        <td class="form-label">
			            To do:
			        </td>
			        <td class="form-input">
			            <input type="text" name="group-name" style="width: 200px;" class="text" value="<?php echo $data['name'] ?>">
			        </td>
			    </tr>
			    <tr>
			        <td class="form-label">
			            Permision(Access control):
			        </td>
			        <td class="form-input">
			        	<table bordercolor="#cccccc" border="1" width="100%" cellpadding="0" style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">
			                <tbody><tr>
			                    <td valign="top">
			                        <table class="no-tb">
				                        <tbody>
				                            <tr class="well">
				                                <td align="center" width="10">
				                                    <input type="checkbox" class="big-checker">
				                                </td>
				                                <td>Tour management</td>
				                            </tr>
				                            <tr>
				                                <td><input type="checkbox" name="roles[]" value="tour" <?php checkRoles($roles, 'tour'); ?>></td>
				                                <td>Tour</td>
				                            </tr>
				                            <tr>
				                                <td><input type="checkbox" name="roles[]" value="tour-category" <?php checkRoles($roles, 'tour-category'); ?>></td>
				                                <td>Tour category</td>
				                            </tr>
				                            <tr>
				                                <td><input type="checkbox" name="roles[]" value="tour-style" <?php checkRoles($roles, 'tour-style'); ?>></td>
				                                <td>Trip in style</td>
				                            </tr>
			                            </tbody>
			                        </table>
			                    </td>
			                    <td valign="top">
			                        <table class="no-tb">
			                            <tbody>
				                            <tr class="well">
				                                <td align="center" width="10">
				                                    <input type="checkbox" class="big-checker">
				                                </td>
				                                <td>Cruise and Hotel</td>
				                            </tr>
				                            <tr>
				                                <td><input type="checkbox" name="roles[]" value="cruise-itinerary-tour" <?php checkRoles($roles, 'cruise-itinerary-tour'); ?>></td>
				                                <td>Cruise - Tour</td>
				                            </tr>
				                            <tr>
				                                <td><input type="checkbox" name="roles[]" value="cruise" <?php checkRoles($roles, 'cruise'); ?>></td>
				                                <td>Cruise</td>
				                            </tr>
				                            <tr>
				                                <td><input type="checkbox" name="roles[]" value="cruise-category" <?php checkRoles($roles, 'cruise-category'); ?>></td>
				                                <td>Cruise category</td>
				                            </tr>
				                            <tr>
				                                <td><input type="checkbox" name="roles[]" value="cruise-type" <?php checkRoles($roles, 'cruise-type'); ?>></td>
				                                <td>Cruise Type</td>
				                            </tr>
				                            <tr>
				                                <td><input type="checkbox" name="roles[]" value="cruise-itinerary" <?php checkRoles($roles, 'cruise-itinerary'); ?>></td>
				                                <td>Type itinerary</td>
				                            </tr>

				                            <tr>
				                                <td><input type="checkbox" name="roles[]" value="hotel" <?php checkRoles($roles, 'hotel'); ?>></td>
				                                <td>Hotel</td>
				                            </tr>
				                            <tr>
				                                <td><input type="checkbox" name="roles[]" value="hotel-type" <?php checkRoles($roles, 'hotel-type'); ?>></td>
				                                <td>Hotel type</td>
				                            </tr>
			                            </tbody>
			                        </table>
			                    </td>
				                <td valign="top">
		                                <table class="no-tb">
		                                    <tbody>
		                                        <tr class="well">
		                                            <td align="center" width="10">
		                                                <input type="checkbox" class="big-checker">
		                                            </td>
		                                            <td>Sell Management</td>
		                                        </tr>
		                                        <tr>
		                                            <td><input type="checkbox" name="roles[]" value="customer" <?php checkRoles($roles, 'customer'); ?>></td>
		                                            <td>Customer</td>
		                                        </tr>
		                                        <tr>
		                                            <td><input type="checkbox" name="roles[]" value="order" <?php checkRoles($roles, 'order'); ?>></td>
		                                            <td>Order</td>
		                                        </tr>
		                                        <tr>
		                                            <td><input type="checkbox" name="roles[]" value="order-status" <?php checkRoles($roles, 'order-status'); ?>></td>
		                                            <td>Order type</td>
		                                        </tr>
		                                        <tr>
		                                            <td><input type="checkbox" name="roles[]" value="payment-type" <?php checkRoles($roles, 'payment-type'); ?>></td>
		                                            <td>Payment type</td>
		                                        </tr>
		                                    </tbody>
		                                </table>
			                    </td>
				                <td valign="top">
		                                <table class="no-tb">
		                                    <tbody>
		                                        <tr class="well">
		                                            <td align="center" width="10">
		                                                <input type="checkbox" class="big-checker">
		                                            </td>
		                                            <td>Enquire vs Contact</td>
		                                        </tr>
		                                        <tr>
		                                            <td><input type="checkbox" name="roles[]" value="enquire" <?php checkRoles($roles, 'enquire'); ?>></td>
		                                            <td>Enquire</td>
		                                        </tr>
		                                        <tr>
		                                            <td><input type="checkbox" name="roles[]" value="contact" <?php checkRoles($roles, 'contact'); ?>></td>
		                                            <td>Contact</td>
		                                        </tr>
		                                    </tbody>
		                                </table>
		                            </td>
	                            </tr>
				                <tr>
				                    <td valign="top">
				                        <table class="no-tb">
				                            <tbody>
				                              <tr class="well">
					                                <td align="center" width="10">
					                                    <input type="checkbox" class="big-checker">
					                                </td>
					                                <td>Article management</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="event" <?php checkRoles($roles, 'event'); ?>></td>
					                                <td>MICE</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="visa" <?php checkRoles($roles, 'visa'); ?>></td>
					                                <td>Visa</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="faqs" <?php checkRoles($roles, 'faqs'); ?>></td>
					                                <td>FAQS</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="faqs-category" <?php checkRoles($roles, 'faqs-category'); ?>></td>
					                                <td>FAQS type</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="article" <?php checkRoles($roles, 'article'); ?>></td>
					                                <td>Article</td>
					                            </tr>
					                        </tbody>
					                    </table>
				                    </td>
				                    <td valign="top">
				                        <table class="no-tb">
				                            <tbody>
				                              <tr class="well">
					                                <td align="center" width="10">
					                                    <input type="checkbox" class="big-checker">
					                                </td>
					                                <td>Photo Manager</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="ckfinder" <?php checkRoles($roles, 'ckfinder'); ?>></td>
					                                <td>CkFinder</td>
					                            </tr>
					                        </tbody>
					                    </table>
				                    </td>
				                    <td valign="top">
				                        <table class="no-tb">
				                            <tbody>
					                            <tr class="well">
					                                <td align="center" width="10">
					                                    <input type="checkbox" class="big-checker">
					                                </td>
					                                <td>Other infomation</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="country" <?php checkRoles($roles, 'country'); ?>></td>
					                                <td>Country</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="country-article" <?php checkRoles($roles, 'country-article'); ?>></td>
					                                <td>Article about country</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="area" <?php checkRoles($roles, 'area'); ?>></td>
					                                <td>Area</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="region" <?php checkRoles($roles, 'region'); ?>></td>
					                                <td>City - Province</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="area-destination" <?php checkRoles($roles, 'area-destination'); ?>></td>
					                                <td>Area Destination</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="region-destination" <?php checkRoles($roles, 'region-destination'); ?>></td>
					                                <td>Destination</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="vietnam-travel-destination" <?php checkRoles($roles, 'vietnam-travel-destination'); ?>></td>
					                                <td>Viet Nam travel distination</td>
					                            </tr>
					                        </tbody>
					                    </table>
				                    </td>
				                    <td valign="top">
				                        <table class="no-tb">
				                            <tbody>
					                            <tr class="well">
					                                <td align="center" width="10">
					                                    <input type="checkbox" class="big-checker">
					                                </td>
					                                <td>System management</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="vct-info" <?php checkRoles($roles, 'vct-info'); ?>></td>
					                                <td>VCT Info</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="vct-setting" <?php checkRoles($roles, 'vct-setting'); ?>></td>
					                                <td>VCT Setting & Reply message</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="gallery" <?php checkRoles($roles, 'gallery'); ?>></td>
					                                <td>Gallery slide show</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="support" <?php checkRoles($roles, 'support'); ?>></td>
					                                <td>Online supporter</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="user" <?php checkRoles($roles, 'user'); ?>></td>
					                                <td>User management</td>
					                            </tr>
					                            <tr>
					                                <td><input type="checkbox" name="roles[]" value="user-group" <?php checkRoles($roles, 'user-group'); ?>></td>
					                                <td>Group user management</td>
					                            </tr>
					                        </tbody>
					                    </table>
				                    </td>
				                </tr>
			            	</tbody>
			            </table>
			        </td>
			    </tr>
			    <tr>
			        <td class="form-label">
			            Ghi chú:
			        </td>
			        <td class="form-input">
			            <textarea name="description"></textarea>
			        </td>
			    </tr>
			    <tr>
			        <td class="form-label"></td>
			        <td class="form-input">
			            <input type="submit" class="btn btn-primary" value="Save">
			            <a href="admin/user-group/index" class="btn">Reset</a>
			        </td>
			    </tr>
			</tbody>
		</table>
</div>
</form>
<style>
.form-label{width:150px;font-weight:bold}
.no-tb{width:100%}
.no-tb td{padding:5px}
</style>
<script>$(function(){$('.big-checker').live('click', function(e){$(this).parent().parent().parent().slice(0,1).find('input[name*=roles]').attr('checked',this.checked);});});</script>